import './index.html';
import './index.less';
import dva from 'dva';
import moment from 'moment';
import 'moment/locale/zh-cn';
moment.locale('zh-cn');
Number.prototype.formatMoney = function(places, symbol, thousand, decimal) {
	places = !isNaN(places = Math.abs(places)) ? places : 0;
	symbol = ""; //symbol !== undefined ? symbol : "$";
	thousand = thousand || ",";
	decimal = decimal || ".";
	var number = this,
		negative = number < 0 ? "-" : "",
		i = parseInt(number = Math.abs(+number || 0).toFixed(places), 10) + "",
		j = (j = i.length) > 3 ? j % 3 : 0;
	return symbol + negative + (j ? i.substr(0, j) + thousand : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousand) + (places ? decimal + Math.abs(number - i).toFixed(places).slice(2) : "");
};

Date.prototype.formatAdd = function(add, fmt) {
	if (!fmt) {
		fmt = "yyyy-MM-dd"
	}
	var a = new Date(this.valueOf() + add * 24 * 60 * 60 * 1000);
	var o = {
		"M+": a.getMonth() + 1, //月份
		"d+": a.getDate(), //日
		"h+": a.getHours(), //小时
		"m+": a.getMinutes(), //分
		"s+": a.getSeconds(), //秒
		"q+": Math.floor((a.getMonth() + 3) / 3), //季度
		"S": a.getMilliseconds() //毫秒
	};
	if (/(y+)/.test(fmt))
		fmt = fmt.replace(RegExp.$1, (a.getFullYear() + "").substr(4 - RegExp.$1.length));
	for (var k in o)
		if (new RegExp("(" + k + ")").test(fmt))
			fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
	return fmt;
}

// 1. Initialize
const app = dva();

// 2. Model
app.model(require('./models/homePage'));

app.model(require('./models/BusinessData'));

app.model(require('./models/TableList'));
app.model(require('./models/UserEdit'));
app.model(require('./models/UserForm'));
app.model(require('./models/PersonsInfo'));
app.model(require('./models/PersonsCustom'));
app.model(require('./models/PersonsSource'));
app.model(require('./models/ProductNeed'));
//app.model(require('./models/Marketing'));
app.model(require('./models/MarketingOnline'));
app.model(require('./models/MarketingOffline'));
app.model(require('./models/UserViscosity'));
app.model(require('./models/UserActivity'));
app.model(require('./models/UserValue'));
app.model(require('./models/UserView'));
app.model(require('./models/SocialInfluence'));
app.model(require('./models/BuyChannel'));

app.model(require('./models/CRMdata'));

// 3. Router
app.router(require('./router'));

// 4. Start
app.start('#root');
